from base import Yaml, Path
from page import WebPage


class ZentaoLoginPage(WebPage):
    """
    author: ArtLinty
    email: hello@linty.art
    desc: 禅道企业版 登录页面业务
    """
    __config = Yaml.get_config_as_dict(
        Path.get_actual_path_by_current_file(__file__, "web.yml")
    )["ZentaoLoginPage"]

    def login(self, account, password):
        """
        登录
        :param account:
        :param password:
        :return: 当前 URL
        """

        browser = self.driver
        yml = self.__config

        yml_location = yml["LOCATOR"]
        browser.type(yml_location["ACCOUNT_INPUT"], account)
        browser.type(yml_location["PASSWORD_INPUT"], password)
        browser.click(yml_location["SUBMIT_BUTTON"])

        return self.current_url
